1 package mobisnap.mobile_trx; 2 3 /*** 4 * Used to represent variables and constants internally 5 */ 6 public class MSQLTVarChar extends MSQLTVariable 7 { 8 int size; 9 10 public MSQLTVarChar( boolean constant, boolean notnull, int size) { 11 super( constant, notnull); 12 this.size = size; 13 } 14 15 /*** 16 * Sets the value of the given variable 17 */ 18 public void setValue( Object obj) throws Exception { 19 if( constant && value != null) 20 throw new mobisnap.MobisnapException( "Assigning value to constant"); 21 if( obj instanceof String) { 22 if( size > 0 && ((String)obj).length() > size) 23 value = ((String)obj).substring( 0, size); 24 else 25 value = obj; 26 } else if( obj instanceof SQLNull && ! notnull) 27 value = obj; 28 else if( obj instanceof java.sql.Date) 29 setValue( obj.toString()); 30 else if( obj instanceof Boolean || MSQLTypeUtil.isDecimal( obj)) 31 setValue( obj.toString()); 32 else 33 throw new mobisnap.MobisnapException( "Invalid assgnment to var char : " + obj.getClass().getName()); 34 } 35 }

This page was automatically generated by Maven